#ifndef MUSICCONTROLLER_H
#define MUSICCONTROLLER_H

#include <QObject>
#include <QMediaPlayer>

#include "jsonrpcservice.h"


class MusicController : public JsonRpcService
{
    Q_OBJECT

    Q_CLASSINFO("serviceName", "MusicController")

public:
    MusicController();
    virtual ~MusicController();


public slots:
    /**
     * @brief load loads a track from its filename
     * @param url
     */
    void load(QString url);

    /**
     * @brief playPause plays or pauses the track alternatively. If the player is stopped then it plays
     *
     */
    void playPause();

    /**
     * @brief stop stops the current track and unload it
     * @param p
     */
    void stop();


    void setPosition(qint64 poition);

    /**
     * @brief setPosition sets the time position asked by the client
     * @param position
     */
    void setClientPosition(qint64 posistion);

    void setClientTimeRange(qint64 duration);
    void updateClientTimeRange();


    /**
     * @brief setVolume sets the volume asked by the client
     * @param params
     */
    void setClientVolume(int volume);


    void changeClientMetaData();


signals:
    void trackLoaded();

private:
    bool isPlaying;
    QMediaPlayer *p_player;
};




#endif // MUSICCONTROLLER_H
